<!DOCTYPE html>
<head>

    <title>订单页</title>

    @include('web.layout.head')
    @include('web.layout.header_proscenium')
    <link rel="stylesheet" href="{{mix('/css/web/order/submin_cart.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/order/cart.css')}}">
    <link rel="stylesheet" href="{{asset('/js/web/frame/layer-v3.0.3/layer/skin/default/layer.css')}}">
</head>
<body>
<div class="shopcar-header">
    <div class="w1200 f-cb">
        <a class="logo fl" href="{{asset('/')}}"><img src="{{asset('/img/web/logo/forget_logo.png')}}" alt=""></a>
        <div class="tit fl">资质确认页</div>
        <!-- <img class="flow fr" src="{{asset('/img/web/order/img115.jpg')}}" alt="" class="fr"> -->
        <img class="flow fr" src="{{asset('/img/web/order/zizhi1.png')}}" alt="" class="fr">
        <!-- <img class="flow1 fr" src="{{asset('/img/web/order/img1151.jpg')}}" alt="" class="fr"> -->

    </div>
</div>

<div class="width1200 shopcar-wrap" style="min-height: 600px;">
    <form action="{{url('/member/buyer/attribute')}}" method="post" accept-charset="utf-8" class="form-horizontal" id="frm-post-login" name="frm-post">
        {{csrf_field()}}
        <div class="cart-service-tab">
            <table width="100%">
                <thead>
                <tr>
                    <th width="280">资质名称</th>
                    <th width="120">级别</th>
                    <th width="200">收费标准</th>
                    <th width="253">费用类型</th>
                    <th width="107">金额</th>
                    <th width="200">服务商</th>
                </tr>
                </thead>
                    @if(!empty($shops))
                    <input type="hidden"  name="shop_id" value="{{$shops['sp_id']}}">
                    <input type="hidden"  name="shop_name" value="{{$shops['sp_name']}}">
                        @foreach(($shops['attris'][0]) as $k=>$v)
                        <tr>
                            <input type="hidden" name="attri[{{$k}}][product_id]" value="{{$v['product']['id']}}"/>
                            <input type="hidden" name="attri[{{$k}}][price]" value="{{$v['price']}}"/>
                            <input type="hidden" name="attri[{{$k}}][product_img_url]" value="{{$v['product']['cover_image']}}"/>
                            <input type="hidden" name="attri[{{$k}}][product_name]" value="{{$v['product']['name']}}"/>
                            <input type="hidden" name="attri[{{$k}}][attributes]" value="{{$v['attributes']}}"/>
                            <td>{{$v['product']['name']}}</td>
                            @if(isset($v['attrs']))
                                <td>{{$v['attrs']['level']}}</td>
                           @endif
                            <td>
                                @if(isset($v['attrs']))
                                    @if(isset($v['attrs']['text']))
                                        @foreach($v['attrs']['text'] as $key=>$val)
                                            <span>{{$key}}.{{$val}}</span>
                                        @endforeach
                                    @endif
                                @endif
                            </td>
                            <td>印章费</td>
                            <td>￥{{$v['price']}}</td>
                            <td>{{$shops['sp_name']}}</td>
                        </tr>
                    @endforeach
                    @else
                    <tr class="product_normal">
                        <td colspan='6' style='text-align: center;'>没有数据</td>
                    </tr>
                    @endif
                    {{--<tr>--}}
                        {{--<td>信息系统集成与服务资质</td>--}}
                        {{--<td>一级</td>--}}
                        {{--<td>--}}
                            {{--<span>1.印章费：3000元</span>--}}
                            {{--<span>2.中标实施：项目金额3%</span>--}}
                            {{--<span>(中标后退印章费)</span>--}}
                        {{--</td>--}}
                        {{--<td>印章费</td>--}}
                        {{--<td>￥3000.00</td>--}}
                        {{--<td>杭州三三安防服务公司</td>--}}
                    {{--</tr>--}}

            </table>
        </div>

        <div class="demand_main">
            <div class="h2_tit">填写您的需求信息</div>
            <div class="input_box">
                <span class="fl">*</span><font class="fl">投标日期</font><input name="bid_date" class="bidTime" id="bidTime" type="text" required>
                <input name="project_name" class="entryName fr" id="entryName" type="text">
                <font class="fr">项目名称</font>
            </div>
            <div class="entryInto_box">
                <span>项目信息（<font>选填</font>）：</span>
                <textarea name="project_inf" id="project_inf" maxlength="500" placeholder="请填写您的附加要求，例如需要额外提供功能或服务"></textarea>
                <div class="enclosure_box fr">
                    <img id="rnclosure_btn" src="{{asset('img/web/order/rnclosure_btn.jpg')}}">
                    <input type="file" name="file" id="fileupload">
                    <p>更多要求请放在附件，如果您有相关资料也可以传给服务商参考</p>
                    <span id="entryInto_num">0/500</span>
                    <font>最多可上传5个10M以内的JPG、PNG、GIF、DOC、DOCX、RAR、ZIP文件</font>
                    <!-- <input type="hidden" value="" name="enclosure[]"> -->
                </div>
            </div>
        </div>
        <div class="invoice_main">
            <div class="invoice_left fl  invoice_shop_content_{{$shops['sp_id']}}">
                <input type="hidden" class="invoice_shop_{{$shops['sp_id']}}" name="invoices[{{$shops['sp_id']}}]" value="{{$default_invoice ? $default_invoice['id'] : ''}}">

                <div class="tit">
                    发票管理:
                    <span class="invoice_type">
                    @if($default_invoice)
                            @if($default_invoice['invoice_message'] == 1)
                                个人发票
                                <?php $default_invoice_type = 'personal_invoice';?>
                            @else
                                {{$default_invoice['invoice_type'] == 1 ? '普通发票' : '专用发票'}}
                                @if($default_invoice['invoice_type'] == 1)
                                    <?php $default_invoice_type = 'company_regular_invoice';?>
                                @else
                                    <?php $default_invoice_type = 'company_special_invoice';?>
                                @endif
                            @endif
                        @else
                            不开发票
                            <?php $default_invoice_type = 'no_invoicing';?>
                        @endif
                    </span>
                    <span class="edit" data-shop-id="{{$shops['sp_id']}}" table-key=1>修改</span>
                </div>

                <div class="invoice_name">{{$default_invoice ? $default_invoice['invoice_title'] : '不开发票'}}</div>
                <a class="a_invoices fl" href="{{asset('/member/buyer/invoices')}}"  target="_blank">管理发票信息</a>
            </div>
            <div class="invoice_right fl">
                <div class="tishi">温馨提示：发票的开票金额仅限实际金额（不包括积分抵扣等优惠部分）。<a>了解详情＞＞</a></div>
                <div class="tishi">每月25日（含25日）之后的付款订单，将在下月开具发票</div>
                <div class="fl remark">
                    <span class="fl bz">备注：</span>
                    <input name='remark'  type="text" class="fl tex content" placeholder="补充填写其他信息，如有快递不到也请留言备注" />
                </div>
            </div>
        </div>
        <div class="bot-operate-service f-cb">
            <input type="button" class="fr sub-service-btn product_normal" id="sub-btn" value="确定">
        </div>
    </form>
</div>
<div class="mask"></div>
<div class="editinvoce">
    <div class="title">发票信息
        <img  class="close_img" src="{{asset('/img/web/order/img121.png')}}">
    </div>
    <div class="lx">
        <ul>
            <li invoice-message-type='2' class="xz first_invoice company_regular_invoice" data-target="company_regular_invoice">普通发票</li>
            <li invoice-message-type='3' data-target="company_special_invoice" class="company_special_invoice">增值发票</li>
            <li invoice-message-type='1' data-target="personal_invoice" class="personal_invoice">个人</li>
            <li invoice-message-type='0' data-target="no_invoicing" class="no_invoicing">不开发票</li>
        </ul>
    </div>
    <div class="invoice_select">

    </div>

    <div class="invoice_btn btn">确定</div>
</div>
<div class="suc_bg">
    <div class="suc_box">
        <div class="suc_box_top">
            <span class="cha">×</span>
        </div>
        <div class="suc_box_con">
            <div class="suc_box_img">
                <img src="{{asset('/img/web/inc/icon/success_big.png')}}" alt="">
            </div>
            <div class="suc_box_right">
                <h3 class="suc_box_right_tit">订单提交成功!请等待资质方确认</h3>
                <h4 class="suc_box_right_tit_two">可以使用e井通讯，以便尽快联系到资质方</h4>
                <p class="suc_box_num">订单编号：<span id="ret_order_code">75443514215581</span></p>
                <p class="suc_box_num">支付金额：<span id="ret_total_money">7788.00元</span></p>
                <p class="suc_box_num">商家名称：<span id="ret_shop_name">杭州奥策科技有限公司</span></p>
            </div>
        </div>
        <div class="suc_box_bom">
            <a href="{{url('/member/buyer/service/order')}}" class="look">查看我的服务订单</a>
            <a href="{{url('/')}}" class="back">返回网站首页</a>
        </div>
    </div>
</div>
@include('web.layout.footer_ware1')
</body>
<link rel="stylesheet" href="{{asset('/frame/jedate/jedate.css')}}">
<script src="{{asset('/frame/jedate/jedate.js')}}"></script>
<script src="{{mix('/js/web/frame/distpicker.js')}}"></script>
<script type="text/javascript">
    jeDate('#bidTime',{
        format:"YYYY-MM-DD",
        minDate: jeDate.nowDate(0)
    });
    var invoice_list = '/member/buyer/invoices?type=order_select';
    var current_shop_id = '';
    var current_type = '{{$default_invoice_type}}';
    $(document).ready(function () {

        /* textarea字数*/
        var text2=$("#project_inf").val();
        var counter2=text2.length;
        $("#entryInto_num").text(counter2+'/500');
        $("#project_inf").on('blur keyup input',function(){
            var text=$("#project_inf").val();
            var counter=text.length;
            $("#entryInto_num").text(counter+'/500');
        });

        $('#fileupload').change(function(){
            // 附件不超过5个
            if($("input[name='enclosure[]']").length >= 5){
                layer.alert('上传附件不超过5个', {
                    title:'提示',
                    icon: 2
                });
                return false;
            }
            var url = AJAX_URL + '/uploads/images';

            var file = this.files;    //获取上传的文件
            //var fileName = file[0].name;
            var fileSize = (file[0].size/1024).toFixed(2);
            // 附件大小不超过10240KB；
            if(fileSize > 10240){
                layer.alert('上传附件不超过10M', {
                    title:'提示',
                    icon: 2
                });
                return false;
            }
            var formFile = new FormData();
            formFile.append("image", file[0]);
            console.log(formFile);
            $.ajax({
                url: url,
                type: "POST",
                data: formFile,
                dataType:"json",
                contentType: false,
                cache: false,
                processData: false,
                success: function (res) {
//                    if (res.status == 0){
                        var html = '<input type="hidden" value="'+res.path+'" name="enclosure[]">';
                        $(".enclosure_box").append(html);
//                    } else {
                        layer.alert('上传成功', {
                            title:'提示',
                            icon:1
                        });
//                    }
                },
                error: function () {
//                    console.log("error");
                    layer.alert('上传失败', {
                        title:'提示',
                        icon: 2
                    });
                }
            });
        })
        $("#rnclosure_btn").click(function () {
            $("#fileupload").trigger("click");

        });
        //发票修改
        $(".edit").click(function(){
            current_shop_id = $(this).data('shop-id');
            $.ajax({
                url: invoice_list,
                type: 'get',
                data:{current_type:current_type},
                success:function(html){
                    $('.invoice_select').html(html);
                }
            });
            $(".lx ul li").removeClass('xz');

            if(current_type=='no_invoicing'){
                $(".no_invoicing").addClass('xz');
            }else{
                var li = $(".lx ul ."+current_type)[0];
                $(li).trigger('click');
            }

            if($('.invoice_select .personal_invoice').find('.invoice_data').length < 1){
                $(".invoice_btn").hide();
            }else{
                $(".invoice_btn").show();
            }
            setTimeout(function(){
                $(".editinvoce").show();
                $(".fpdt").show();
            },200);
         })
        $(".lx ul li").click(function(){
            // 选项卡选择不更改全局发票选择状态。确认按钮更改发票状态。
            _this_current_type = $(this).data('target');
            //选择发票类型
            if($('.' + _this_current_type).find('.invoice_data').length < 1){
                $(".invoice_btn").hide();
            }else{
                $(".invoice_btn").show();
            }
            $('.invoice_select .invoices_content_list').hide();
            $('.invoice_select .' + _this_current_type).show();
            //更换高亮
            $(".lx ul li").removeClass('xz');
            $(this).addClass('xz');
        })
        $(".invoice_btn").click(function(){
            // 当前发票类型应该根据 点击了确认之后的类型相同。
            choose = $('.lx ul .xz'); // 选择被选中的 li 即发票信息
            current_type = $(choose).data('target');

            var $invoice_data = $('.' + current_type).find('.invoice_data');
            var invoice_id = $invoice_data.data('invoice-id');
            var invoice_type = $invoice_data.data('type');
            var invoice_title = $invoice_data.data('title');
            $('.invoice_shop_'+current_shop_id).val(invoice_id);
            $('.invoice_shop_content_'+current_shop_id).find('.invoice_type').text(invoice_type);
            $('.invoice_shop_content_'+current_shop_id).find('.taitou').text(invoice_title);
            $(".editinvoce").hide();
        });
        $(".close_img").on('click',function(event) {
            event.preventDefault();
            /* Act on the event */
            $(".editinvoce").hide();
        });
        $(".invoice_manage").on('click',function(event) {
            event.preventDefault();
            /* Act on the event */
            location.href = '/member/inovce_list';
        });
        $("#sub-btn").on('click',function() {
            var bidTime=$('#bidTime').val();
            if(bidTime==''){
                layer.alert('请输入项目时间', {
                    icon: 2
                });
                return false;
            }
            $.ajax({
                url: "{{url('/member/buyer/attribute')}}",
                type: 'POST',
                dataType: 'json',
                data: $("#frm-post-login").serializeArray(),
                success: function (data) {
                    if (data.code == 0) {
                        $('#ret_order_code').html(data.data.order_code);
                        $('#ret_total_money').html(data.data.total_money +'元');
                        $('#ret_shop_name').html(data.data.shop_name);
                        $(".suc_bg").show();
                    } else {
                        layer.alert(data.message, {
                            icon: 0
                        });
                    }
                }

            })
        })
        $(".suc_box_top .cha").on('click',function() {
            $(".suc_bg").hide();
        })
    })
</script>
</html>